<template>
  <div class="child-container">
    <div>Child</div>
    <div>str：{{ str }}</div>
    <el-button @click="childTest">调用父组件的方法并传值</el-button>
  </div>
</template>

<script>
export default {
  props: {
    str: {
      required: true,
      type: String,
      default: "默认",
    },
  },
  methods: {
    childTest() {
      this.$emit("test", "我是子组件，调用父组件的方法并传值");
    }
  },
};
</script>

<style lang="scss" scoped></style>